﻿using System;
using PM.BusinessLayer;
using PM.Entities;

public partial class UserManagement_Data : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void btnAddSubject_Click(object sender, EventArgs e)
    {
        if (tbSubjectName.Text.Length > 3)
        {
            Subject sub = new Subject()
            {
                //SubjectID = int.Parse(grvSubjects.DataKeyNames["SubjectID"].ToString()) ,
                Name = tbSubjectName.Text.ToString()
            };
            new DataController().InsertSubject(sub);
        }
        tbSubjectName.Text = "";
        grvSubjects.DataBind();
        Response.Redirect(Request.RawUrl);
    }

    protected void btnAddGroup_Click(object sender, EventArgs e)
    {
        if (tbGroup.Text.Length != 0)
        {
            Group gr = new Group()
            {
                GroupNumber = int.Parse(tbGroup.Text.ToString())
            };
            new DataController().InsertGroup(gr);
        }
        tbGroup.Text = "";
        grvGroup.DataBind();
        Response.Redirect(Request.RawUrl);
    }

    protected void btnAddSpeciality_Click(object sender, EventArgs e)
    {
        if (tbSpeciality.Text.Length > 1)
        {
            Speciality sp = new Speciality()
            {
                Name = tbSpeciality.Text.ToString()
            };
            new DataController().InsertSpeciality(sp);
        }
        tbSpeciality.Text = "";
        grvSpiciality.DataBind();
        Response.Redirect(Request.RawUrl);
    }

}
